from time import sleep
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://www.baidu.com")
print("Before search===================================")
#打印当前页的title
title = driver.title
print("title:"+title)
#打印当前页的URL
url = driver.current_url
print("URL:"+url)
driver.find_element_by_id("kw").send_keys("selenium")
driver.find_element_by_id("su").click()
sleep(5)
print("After search========================")
#再次打印当前页的title
title = driver.title
print("title:"+title)
#再次打印当前页的URL
url = driver.current_url
print("URL:"+url)
#获取搜索条数
num = driver.find_element_by_class_name("nums").text
print("reselt:"+num)
sleep(5)
driver.quit()